<template>
  <div class="add-network">
    <van-field
      v-model="networkName"
      type="text"
      label="网点名称"
      placeholder="请填写"
      :error-message="errorMessage"
      clearable
    />
    <div class="save-btn">
      <baseBtn
        :txt="txt"
        @handleClick="handleSub"
      />
    </div>
  </div>
</template>

<script type="text/ecmascript-6">
  import baseBtn from '../../components/BaseBtn.vue'
  export default {
    components: {
      baseBtn
    },
    data() {
      return {
        networkName: '',
        txt: '保存并使用',
        errorMessage: '',
      }
    },
    watch:{
      networkName(newV, oldV) {
        if(newV.length > 0) {
          this.errorMessage = ''
        }
      }
    },
    methods: {
      handleSub() {
        if(this.networkName == '') {
          this.errorMessage = '请填写网点名称'
          return false
        } else {
          console.log(this.networkName)
        }
      }
    },
  }
</script>

<style scoped>
.add-network .save-btn{margin-top: 20px;padding:0 15px;box-sizing: border-box}
</style>
